/**
 * Author: w景洋.
 * Time: 2016/4/19 0019
 */
angular.module('service.goods', [
    "ngResource"
])
    //商品服务
    .service('MenuGoodsService',['$resource',function($resource){
        var Menu = $resource(mallurl+'/menu/bycate/:id', {}, {
            get: {cache: true, method: 'GET'},
            query: {cache: true, method: 'GET', isArray: true}
        });
        //var Menu = $resource(mallurl+'/menu/:id', {}, {
        //    get: {cache: true, method: 'GET'},
        //    query: {cache: true, method: 'GET', isArray: true}
        //});
        //根据店铺id获取商品列表
        this.getMenuByShopid = function(shopid){
            var goodsList = Menu.query({id:shopid});
            return goodsList;
        }

    }])

    //商品服务
    .service('GoodsService',['$resource',function($resource){
        var Goods = $resource(mallurl+'/goods/:id');
        var GoodsSearch = $resource(mallurl+'/goods/bykeyword/:keyword');

        //查询商品详情
        this.getGoodsByGoodsId=function(goodsid){
            return Goods.get({id:goodsid});
        }

        //搜索商品
        this.queryGoodsListByKeyword = function(keyword){
            //console.log('queryGoodsListByKeyword('+keyword+')');
            return GoodsSearch.query({keyword:keyword});
        }
    }])
;
